#include <Arduino.h>
#include <lvgl/lvgl.h>
#include <stdio.h>
#include "BluetoothSerial.h"
#include "cJSON.h"
#include <math.h>

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif

/*界面定义*/
#ifndef __WIDGET__
#define __WIDGET__

/*各界面父对象指针*/
lv_obj_t * main_widget;
lv_obj_t * tileview;
lv_obj_t * tabview;
lv_obj_t * calendar_widget;

/*家居控制中三个页面父指针*/
lv_obj_t * tab1;
lv_obj_t * tab2;
lv_obj_t * tab3;

/*家居状态切换对象指针*/
lv_obj_t * img_light_off = NULL; //灯关闭状态图片指针对象
lv_obj_t * img_light_on = NULL;  //灯打开状态图片指针对象
lv_obj_t * img_air_off = NULL;   //空调关闭状态图片指针对象
lv_obj_t * img_air_on = NULL;    //空调打开状态图片指针对象
lv_obj_t * img_cur_on = NULL;
lv_obj_t * img_cur_off = NULL;
lv_obj_t * cur_roller = NULL;
lv_obj_t * cur_slider = NULL;
lv_obj_t * user_label = NULL;

lv_obj_t * watch_time_widget;
lv_obj_t * watch_widget;

lv_obj_t * sport;
lv_obj_t * label_acc = NULL;
lv_obj_t * label_step = NULL;

#endif

/*待机时钟定义*/
#ifndef __WTACH_TIME__
#define __WTACH_TIME__

LV_IMG_DECLARE(watch_bg);
LV_IMG_DECLARE(hour);
LV_IMG_DECLARE(minute);
LV_IMG_DECLARE(second);

lv_obj_t *central;
lv_obj_t *lvMinute;
lv_obj_t *lvHour;
lv_obj_t *lvSecond;

/*转换 __TIME__ 函数*/
static uint8_t conv2d(const char *p);

/*时钟函数*/
lv_task_cb_t update_time(void *arg);
void analog();

uint8_t hh = conv2d(__TIME__), mm = conv2d(__TIME__ + 3), ss = conv2d(__TIME__ + 6); // Get H, M, S from compile time

#endif
